/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.skatiger.jrove.spring.form.component;

import org.skatiger.jrove.renderer.Html;
import org.springframework.util.Assert;

public class InputMultiChecked extends FormInputElement {
    public static final String DEFAULT_VAR = "item";
    private Object items;
    private String itemValue;
    private String var;
    private String element;

    /**
     * Set the {@link java.util.Collection}, {@link java.util.Map} or array of
     * objects used to generate the '<code>input type="checkbox/radio"</code>'
     * tags.
     * <p>
     * Typically a runtime expression.
     * 
     * @param items
     *            said items
     */
    public void setItems(Object items) {
        Assert.notNull(items, "'items' must not be null");
        this.items = items;
    }

    public Object getItems() {
        return getPropertyValue("items", items);
    }

    /**
     * Set the name of the property mapped to the '<code>value</code>' attribute
     * of the '<code>input type="checkbox/radio"</code>' tag.
     * <p>
     * May be a runtime expression.
     */
    public void setItemValue(String itemValue) {
        Assert.hasText(itemValue, "'itemValue' must not be empty");
        this.itemValue = itemValue;
    }

    public String getItemValue() {
        return getPropertyValue("itemValue", itemValue);
    }

    /**
     * Set the HTML element used to enclose the '
     * <code>input type="checkbox/radio"</code>' tag.
     * <p>
     * Defaults to an HTML '<code>&lt;span/&gt;</code>' tag.
     */
    public void setElement(String element) {
        Assert.hasText(element, "'element' cannot be null or blank");
        this.element = element;
    }

    public String getElement() {
        return getPropertyValue("element", element,Html.SPAN_ELEM);
    }

    public void setVar(String var) {
        this.var = var;
    }

    public String getVar() {
        return getPropertyValue("var", var, DEFAULT_VAR);
    }

}
